from tw.api import Widget, WidgetsList

__all__ = ["Grup"]

class Grup(Widget):
	"""
	Widget to grup and display any other widgets.
	you must provide a Slot attribute for displaying in a Site widget.
	>>> from tw.api import WidgetsList
	>>> from tw.lymon import Grup
	>>>	class Component(WidgetsList):
	>>>		a = Widget(template='''<p>HOLA 1</p>''')
	>>>		b = Widget(template='''<p>HOLA 2</p>''')
	>>>		c = Widget(template='''<p>HOLA 3</p>''')
	>>>
	>>>	grup1 = Grup(slot="header.logo.title", children=Component())
	>>> grup1.display()
	u'<p>HOLA 1</p><p>HOLA 2</p><p>HOLA 3</p>'
	
	"""
	params = ['slot']
	slot = ''
	id = slot
	
	engine_name='genshi'
	template = """<div xmlns:py="http://genshi.edgewall.org/" py:for="child in children" py:strip="">${child()}</div>"""
	
	def __init__(self,*k,**kw):
		super(Grup, self).__init__(*k,**kw)
		try:
			self.id = kw['slot'].split(".")[-1]
		except KeyError:
			raise KeyError, "You must probide a slot argument"
		self.slot = kw['slot']
		

	
	
	
	
